/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ssga.utils;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 *
 * @author David
 * 
 * Con esta clase se parsea el XML que contiene los datos de coneccion 
 * con el firebir y se conecta a la base de datos
 */
public class ConexionDB {

    private String user;
    private String password;
    private String url;
    private String driver;
    private String base;
    private Connection conn = null;
    
    
    public void conectar() throws SQLException {
        try {
            Class.forName(this.getDriver()).newInstance();
            String database = "jdbc:odbc:Driver=" + this.getBase() + ";DBQ=" + this.getUrl().trim();
            this.conn = DriverManager.getConnection(database, getUser(), getPassword());
        } catch (Exception err) {
            System.out.println("Error " + err.getMessage());
        }
    }

    /**
     * @return the user
     */
    public String getUser() {
        return this.user;
    }

    /**
     * @param user the user to set
     */
    public void setUser(String user) {
        this.user = user;
    }

    /**
     * @return the password
     */
    public String getPassword() {
        return this.password;
    }

    /**
     * @param password the password to set
     */
    public void setPassword(String password) {
        this.password = password;
    }

    /**
     * @return the url
     */
    public String getUrl() {
        return this.url;
    }

    /**
     * @param url the url to set
     */
    public void setUrl(String url) {
        this.url = url;
    }

    /**
     * @return the driver
     */
    public String getDriver() {
        return this.driver;
    }

    /**
     * @param driver the driver to set
     */
    public void setDriver(String driver) {
        this.driver = driver;
    }

    /**
     * @return the base
     */
    public String getBase() {
        return this.base;
    }

    /**
     * @param base the base to set
     */
    public void setBase(String base) {
        this.base = base;
    }
}
